package cn.xiaoyu.su.strategy;

import java.util.ArrayList;
import java.util.List;

/**
 * 获取表位，短链码的后缀命中哪一张表
 */
public class ShardingTableConfig {

    /**
     * 存储数据表位置编号
     */
    private static final List<String> tableSuffixList = new ArrayList<>();

    static {
        tableSuffixList.add("0");
        tableSuffixList.add("a");
    }

    /**
     * 获取随机后缀
     * @return
     */
    public static String getRandomTableSuffix(String code) {

        int hashCode = code.hashCode();
        int index = Math.abs(hashCode) % tableSuffixList.size();
        return tableSuffixList.get(index);
    }
}
